package com.cn.common.basecon;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import com.cn.common.imp.BaseDao;
import com.cn.model.User;

public class BaseController {

	 protected static final String ERROR_MSG_KEY = "errorMsg";
	 protected static final String USER_CONTEXT="loginuser" ;
	 protected static Map<String , User> map = new HashMap<String,User>();
	 public User loginUser;
	 
	 	//① 获取保存在Session中的用户对象  
	    protected void getSessionUser() {  
	        loginUser = map.get(USER_CONTEXT) ;
	    }  
	     
	     //②将用户对象保存到Session中  
	    protected void setSessionUser(HttpServletRequest request,User user) {  
	          map.put(USER_CONTEXT,user);
	        
	    }  
	      
	    //③ 获取基于应用程序的url绝对路径  
	    public final String getAppbaseUrl(HttpServletRequest request, String url) {  
	        Assert.hasLength(url, "url不能为空");  
	        Assert.isTrue(url.startsWith("/"), "必须以/打头");  
	        return request.getContextPath() + url;  
	    }
	 
}
